package cn.tom.service;


import cn.tom.dao.LargeFileDao;
import cn.tom.entity.LargeFile;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import java.time.Duration;

@Service("fs")
public class LargeFileServiceImpl implements LargeFileService {
    @Autowired
    private LargeFileDao largeFileDao;

    public void add(String id, String filename, byte[] content) {
        LargeFile lf = new LargeFile();
        lf.setId(id);
        lf.setFilename(filename);
        lf.setContent(content);        //向上转型为Object
        largeFileDao.add(lf);
    }


    public String getString(String id) {
        return (String) largeFileDao.findOne(id).getContent();
    }


    public LargeFile findOne(String id) {
        LargeFile buf = largeFileDao.findOne(id);
        return buf;
        //return largeFileDao.findOne(id);
    }


    public void delete(String id) {
        largeFileDao.delete(id);
    }
}
